package com.isasc.demo.pooled.itemqueue;

/**
 * @author: ywy
 * @date: 2023-01-31
 * @desc:
 */
public class TagRecall implements Runnable {

    private RecallQueue<QueueItem> recallQueue;

    public TagRecall(RecallQueue<QueueItem> recallQueue) {
        this.recallQueue = recallQueue;
    }

    @Override
    public void run() {
        // 模拟入队出队频繁
        for (int i = 0; i < 10000; i++) {
            try {
                QueueItem queueItem = recallQueue.recallQueue(QueueItem.class);
                System.out.println(queueItem);
                recallQueue.returnQueue(queueItem);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
